<?php


//if ($_POST["filepath"]) {
$to = "";
$subject = "";
$message = "";

include_once ("httpsqs/httpsqs_client.php");
$httpsqs_host = "localhost";
$httpsqs_port = "1218";
$httpsqs_auth = "";
$httpsqs_charset = "utf-8";
$httpsqs = new httpsqs($httpsqs_host, $httpsqs_port, $httpsqs_auth, $httpsqs_charset);
//curl -d "dtncp /home/hao/test.txt dtn://hao.bytewalla.com"  "http://localhost:1218/?charset=utf-8&name=&opt=put"

$cmd = "dtncpd /home/hao/test/"; //. $_POST["filepath"];
//echo $cmd;
$result = $httpsqs->put("text_java_request", $cmd);
$result = $httpsqs->reset("c_php_reply");
while (1) {
	$result = $httpsqs->get("c_php_reply");
	if ($result != "HTTPSQS_GET_END" && $data != "HTTPSQS_ERROR") {
		//echo $result;
		$file = fopen($result, "r") or exit ("Unable to open file!");
		//Output a line of the file until the end is reached
		$i = 1;
		while (!feof($file)) {
			//echo fgets($file) . "<br />";
			if($i==1){
				$to = fgets($file);
			}else if($i==2){
				$subject = fgets($file);
			}else{
				$message .= fgets($file);
			}
			$i++;
		}
		fclose($file);
		break;
	}
}


//$to = "bytewalla5@googlegroups.com,";
//$subject = "(Don't Reply)Test mail";
//$message = "Hello! This is a test email message.";
$from = "test@bytewalla.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo $to.$from.$msg;
?>